<?php

namespace app\index\controller\promotion;

use app\index\service\PromotionCallbackService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * Callback 控制器
 * Class Callback
 * @package app\index\controller\promotion;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\promotion\Callback
 */
class Callback
{
    // 请求参数
    private Request $request;

    // service
    private PromotionCallbackService $service;

    public function __construct(Request $request, PromotionCallbackService $callbackService)
    {
        $this->request = $request;
        $this->service = $callbackService;
    }

    /**
     * 回传
     * @return ApiResponse
     * @url /promotion/callback/save
     */
    public function save(): ApiResponse
    {
        $request = $this->request;

        $this->service->add($request->param());

        return ApiResponse::success(null);
    }
}
